home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Otherware
/
Otherware_1_SB_Development.iso
/
mac
/
util
/
editor
/
alpha513.cpt
/
Help
/
Alpha Tcl Extensions
< prev
next >
Wrap
Text File
|
1992-10-24
|
15KB
|
284 lines
==============================================================================
= Alpha's Additional Tcl Commands
==============================================================================
In this list of routines, text between '<' and '>' is a placeholder for a
required parameter. Text between '[' and ']' is a placeholder for an
optional parameter, and the '|' signifies a choice of two alternatives.
The following are Alpha-specific tcl routines:
Ñ alertnote message_string
This command will display message_string in a standard Macintosh alert box.
Ñ ascii (see bindings).
Ñ askyesno prompt
This command will display a Macintosh alert box with promptdisplayed with the
push buttons Yes, No, Cancel.. The command will return the title of the button
selected by the user.
Ñ beep
Ñ bind (see bindings)
Ñ blink <pos> - blink cursor at 'pos'
Ñ breakIntoLines <string> - return 'string' with
carriage returns and spaces inserted to satisfy
'leftFillColumn' and 'fillColumn' variables.
Ñ bringToFront <winName> - Bring named window to front.
Ñ cd [directory]
This command will set the current working directory to "directory". The directory
argument may or may not end with a colon. The working directory is the directory
in which file names that contain no colons (folders) will be located with file related
commands. No argument means Alpha's home directory.
Ñ colors <fore red> <fore green> <fore blue> <back red> <back green> <back blue>
Ñ cp <fromName> <toName> [force]
This command will copy the file fromName and name the new file toName. If
toName includes a path name that is different from the path in fromName, the copy
will be made in a new directory (specified by toName). The copy can be made
across volume (disk drives). The force option indicates that the copy should
overwrite any existing file with the same name as toName. This command copies
both data forks, and the Finder information.
Ñ createTMark <name> <pos> - create a temporary 'mark'
at location 'pos'.
Ñ ctime <time>
This command will return a UNIX time string of the format "Wed Feb 19
22:43:36 1992". The parameter time is in Macintosh seconds, and would be the
result of a now or file mtime command or the like.
Ñ deleteText <pos1> <pos2> - remove text between 'pos1'
and 'pos2'
Ñ displayMode <mode> - Up to four characters of the 'mode' string are
displayed in the status line at the bottom of a window.
Ñ dosc <-c 'sign' | -n appName> <-s string | -f fileName> [-t timeout]
Send a 'misc' 'dosc' AppleEvent. Options are the following:
-c 'sign'
"sign" is a four-letter creator signature of a running application.
-n appName
"appName" is the name of a running application.
-s string
"string" is the text of a script to send to the other app.
-f fileName
"fileName" is the complete or relative pathname of a file the other
application should execute.
-t timeout
"timeout" is the number of ticks Alpha should wait for a response. A
timeout of "0" means wait forever.
If neither of the '-c' and '-n' options is chosen, the PPC Browser is
used. Either '-s' or '-f' must be chosen. Thus, you can have "Alpha
5.02" and "Alpha 5.02 Copy" sending Apple events to each other, or they
can send events to a remote server such as Apple's ToolServer.
Ñ echo <string> [<string>...] - echo the strings (used
in shells).
Ñ edit <name> [-r] [-m] - Open a file in a new window. '-r' means open
the file read-only. '-m' means omit the function titlebar menu and
present only the marks titlebar menu, which is labeled with the
contents of 'markLabel'.
Ñ fileMenu [-n name] [-d dir] [-r] [-m] <list of menu items> - Defines a new user
menu named 'name'. The menu is not yet inserted into the menubar. The menu
commands may be nested for heirarchical menus, see 'AlphaBits.tcl' for
examples. Unlike the 'menu' command, when items of this type of menu
are selected the text is interpreted as a file-name, and Alpha attempts
to open that file. '-d' allows defining of a 'dir' argument that is
prepended to every file name before the file is opened. '-n' allows
naming of the menu, '-r' means open the file readonly, while
'-m' means show only the mark menu and use 'markLabel' as it's title.
Ñ get_directory
This command will display a standard Macintosh file dialog and request the user
select a folder. The command will return the selected folder's full path name, or an
empty string if the Cancel button was selected.
Ñ getenv <varname>
This command will return the value of the environment variable varname.
Environment variables are initialized by reading the file Ñtclenv. The environment
file has the format varname=value as in the following example:
TERM=vt100
TCLINIT=::tcl:TclInit.tcl
TCLDEFAULT=
TEST=TEST
TCLPATH=::tcl:tclsh:tclsrc
Ñ getfile <prompt>
This command will display an SFGetFile() and return the full path name of the
selected file, or an empty string if CANCEL button was selected.
Ñ getfinfo <fileName>
This command will display the standard Macintosh file information in the form:
"'aeQL' 'QUIL' lvbsIdm 02/17/92 23:57:12 02/19/92 22:43:36 0,156 219 0".
The fields are the fdCreator, fdType, fdFlags, flCreationDate, flCreationtime,
flModDate, flModTime, fdLocation.H,V, dataForlLength, rsrcForkLength,
respectively. The fdFlags field uses characters to represent bits:
l/L not locaked/Locked
v/V visible/notVisible
b/B not bundled/Bundled
s/S not system/System
i/I not initialized/Initialized
d/D not desktop/Desktop
m/M not sharable/sharable
Ñ getGeometry - return a TCL list containing the left
edge of the current window, the top, the width, and
height.
Ñ getline <prompt> <default>
This command will display a Macintosh alert box with promptdisplayed, a text edit
field with default initially in the field, and with the push buttons OK, Cancel.. The
command will return the text entered into the text edit field by the user, or an empty
string if the user selected the Cancel button.
Ñ getMark - return the current mark.
Ñ getPathName - prompt the user with an SFGetFile dialog and return
complete pathname.
Ñ getPos - return the current insertion point
Ñ getSelect - return the currently selected text, if
any.
Ñ getText <pos1> <pos2> - return the text between 'pos1'
and 'pos2'.
Ñ getVar <name> - return the value of the Alpha variable
'name'.
Ñ glob [-i] [-t <TYPE>] [-c <CRTR>]
The original glob provided by the UNIX version of tcl was not quite
adequate for the more complex Macintosh file system. Issues such as
invisible file handling, Finder type and creator filtering, and space
handling in file names. Release 6 of tcl has dealt with the original
problem with spaces in filenames, but the following options are provided
to deal with additional Macintosh issues.
Anyhow, the new glob now takes several options. They are:
-i This option causes glob to list invisible files also.
-t TYPE This option causes glob to only list file with the
indicated Finder file typeTYPE. This option may be
used with the -c option.
-c CRTR This option causes glob to only list file with the
indicated Finder file creatorCRTR. This option may
be used with the -t option.
Also note that the original glob would skip dot files
(i.e., file names the begin with a period)
in the listing, unless the pattern began with a period.
Tickle extends this concept one step further on the
Macintosh, and skips spot files (i.e., file names that
begin with 'Ñ'), unless the pattern starts with a spot.
Ñ goto <pos> - goto the position 'pos'.
Ñ gotoTMark <name> - goto the temporary mark 'name'.
Ñ hiliteMenuItem <menuName> <itemNum> <on|off> - Either
enable or disable the 'itemNum'th menu item of user
menu 'menuName. Note that unless the menu is not only created, but also
inserted, this command has no effect.
Ñ insertMenu <name> - insert the previously created user
menu 'name' into the menuBar.
Ñ insertText [-w <win name>] <text> [<text>]... - Insert 'text' at the current
insertion point.
Ñ launch -f <name> - launch the named app into the background. Note that
for some yet unexplained reason, some applications (MicroSoft Word)
won't launch completely in the background. 'launch'ing such
applications won't insert the application into any system menu that
specifies running applications (although "About the Finder..." will
list it. The only way to get to such an app is through Alpha's
'switchTo', after which the application will finish launching. The '-f'
option gets around this by launching the application in the foreground
instead.
Ñ lineStart <pos> - return the position of the start of
the line 'pos' is on.
Ñ listpick [-p <prompt>] <list>
This command will display a dialog with the list displayed in a List Manager list. If
the user presses the Cancel button, an empty string is returned. If the user selects
the Open button, or double clicks an item in the list, that item will be returned.
Ñ lookAt <pos> - return the 'pos'th character of the
current file.
Ñ maxPos - returns the number of characters in the front
window.
Ñ menu [-n name] <list of menu items> - Defines a new user
menu named 'name' (if provided). The menu is not yet inserted into
the menubar. The menu commands may be nested for
heirarchical menus, see 'AlphaBits.tcl' for examples.
Alpha massages the function names to make them look better
in the menus.
Ñ message <string> - prints 'string' on the status line.
Ñ mkdir <name> - creates a directory (folder) named
'name' in the current directory.
Ñ moveWin [win name] <left> <top> - moves current or specified window.
Ñ mtime <time> [long|short|abbrev]
Returns a date and time string using the Macintosh International Utilities. The
long/short/abbrev specification corresponds to the date. These are the following
formats:
short 3/16/92 9:20:46 PM
abbrev Mon, Mar 16, 1992 9:20:49 PM
long Monday, March 16, 1992 9:20:43 PM
Ñ mv <fromName> <toName> [force]
This command will move the file fromName to toName. If toName includes a path
name that is different from the path in fromName, the file will be moved into a new
directory (specified by toName). The move can not be made across volume (disk
drives). The force option indicates that the move should overwrite any existing file
with the same name as toName.
Ñ nextLineStart <pos> - return the position of the start
of the next line after position 'pos'.
Ñ now
Returns the current time as Macintosh seconds. This is the number of seconds that
have elapsed since Midnight Jan 1, 1904. Appropriate for input to ctime.
Ñ posToRowCol <pos> - converts from absolute position to row, col.
Ñ prompt <prompt> <default> [<name> <menu item>...]
- prompt dialog to the user with a prompt string and a
default value. The prompt dialog can optionally
include a popup menu specified by 'name' and the
succeeding strings. Selection of the popup menu items
inserts the item text into the editable dialog item.
'Prompt' returns the value of the editable item.
Ñ putenv <varname> <value>
This command will set the environment variable varname to value.
Ñ putfile <prompt> <original>
This command will display an SFPutFile() and return the full path name of the
selected file, or an empty string if CANCEL button was selected. Original is the
default name displayed for the user.
Ñ pwd
This command will return the current working directory.
Ñ removeMenu <name> - remove menu 'name' from menubar.
Ñ removeTMark <name> - remove temporary mark.
Ñ replaceText <pos1> <pos2> <text> - replaces the text
between 'pos1' and 'pos2' with 'text'.
Ñ rm <fileName>
This command will delete the file fileName.
Ñ rowColToPos <row> <col> - converts to abosolute position.
Ñ search <pattern> <pos> [limit] [noFail] - searches for
'pattern' from position 'pos' using current values of
'forward', 'matchWords', 'ignoreCase', and 'regExpr'.
If 'limit' is specified, the search fails if the a
match is not found totally contained between 'pos' and
'limit'. If any fourth argument is specified, a search
failure still results TCL_OK. However, the result of
the call is then just an empty string. If the search
succeeds, a list of two positions will be returned.
The first is the starting position of the match, the
second is one past the last character.
Ñ select <pos1> <pos2> - selects the text between 'pos1'
and 'pos2'.
Ñ selEnd - returns the end of the hilited selection, or
the current insertion point if no text is selected.
Ñ sendToBack <winName> - Sent named window to back.
Ñ setfinfo <fileName> [-a flags] [-c fdCreator] [-t fdTypes]
This command will set the standard Macintosh file information. The flags setting
must be of the same format as displayed by the getfinfo flag.
Ñ setFSets - (see the File Sets section).
Ñ setVar <name> <value> - Sets the Alpha variable 'name'
to 'value'.
Ñ sizeWin [win name] <width> <height> - sets size of current or specified window.
Ñ substituteVars <string> - Takes a single string and
substitutes for all variables inside it, regardless of
depth. Unfortunately, you currently need to make 'global var'
declarations in the proc you call this for each 'var' that might need
to be substituted in the string (see proc.tcl for examples).
Ñ switchTo <appName> - Switches to application 'appName'.
Ñ tclResult - displays a dialog showing the result of
the last TCL evaluation.
Ñ ticks
Returns the current TickCount. Ticks are 60ths of a seconds. TickCount is the
number of ticks since the Macintosh was started. The command:
puts stdout [expr "[ticks] / 60"]
will print the number of seconds since the Macintosh was booted.
Ñ traceFunc on <funcName> <winName> Trace 'funcName', send output to
'winName'.
traceFunc off Turn function tracing off.
traceFunc status Display current tracing status.
Ñ winNames - return a TCL list of all open windows.
Ñ wrapText
Ñ xtclcmd [-f filename] <cmdname> [argument_list]...
This command will load the external command cmdname and pass it the argument
list [ cmdname argument_list... ]. External command are code resources of type
XTCL. They may be located in the resource fork of the tickle application, or they
may be located in a file named XTCL File in the same directory as the tickle
application. If the optional -f filename is included, the external command will first
be loaded from filename before the other two files.
See the appendix for a detailed description of the external tcl command interface.
See the accompanying sources for an example of writing an XTCL.